package com.learn.hibernatevalidator.chapter03.validation;

import jakarta.validation.Constraint;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import jakarta.validation.Payload;

import java.lang.annotation.*;

/**
 * @author: liyf
 * @create: 2025-01-01 22:57
 **/
@Documented
@Constraint(validatedBy = ValidRacingCar.Validator.class)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
public @interface ValidRacingCar {


    String message() default "{org.hibernate.validator.referenceguide.chapter03.validation.ValidRacingCar.message}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    class Validator implements ConstraintValidator<ValidRacingCar, Car> {

        @Override
        public boolean isValid(Car value, ConstraintValidatorContext context) {
            return false;
        }
    }
}
